<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title><%= title %></title>
    <% include ../partial/meta %>
    <link rel="stylesheet" href="/app/static/css/frozen.css">
    <link rel="stylesheet" href="/app/static/css/client.css">
    <link rel="stylesheet" href="/app/static/css/jq.css">
</head>
<body style ="background: #F0F0F0">
    <div style ="background: #473E3C">
        <div class="ui-row-flex ui-whitespace user-profile">
            <div class="ui-col user-avatar">
                <img src="<%= user.user.avatar %>" alt="">
            </div>
            <div class="ui-col ui-col-2 white">
                <p class="gender"><%= user.user.name %>
                    <%
                        if (user.user.gender == 'm') {
                    %>
                    <img src="/app/static/img/boy.png" alt="">
                    <%
                        } else {
                    %>
                    <img src="/app/static/img/girl.png" alt="">
                    <%
                        } 
                    %>
                </p>
                <div class="gen-pro">
                    <p><%= user.user.ageGroup %>后 <%= user.user.constellation %></p>
                    <p><%= user.user.industry %> - <%= user.user.profession %></p>
                </div>
                <%
                    if (user.user.certification) {
                %>
                <div>
                    <img src="/app/static/img/check_ID.png" alt="">
                    <span>实名认证<br>身份信息已认证通过</span>
                </div>
                <%
                    } else {
                %>
                <div class ="check_ID">
                    <img src="/app/static/img/check_ID_no.png" alt="">
                    <span>实名认证<br>身份信息未认证通过</span>
                </div>
                <%
                    } 
                %>
                <%
                    if (user.user.enterpriseAuth) {
                %>
                <div>
                    <img src="/app/static/img/check_company.png" alt="">
                    <span>实名认证<br>身份信息已认证通过</span>
                </div>
                <%
                    } else {
                %>
                <div class ="check_ID">
                    <img src="/app/static/img/check_company_no.png" alt="">
                    <span>企业认证<br>企业信息未认证通过</span>
                </div>
                <%
                    } 
                %>
            </div>
        </div>
    </div>
    <div class="gradient">
        <%
            for(var i =0 ; i < user.user.tags.length && i <= 5; i++) {
        %>
        <li class="ui-col ui-col-16"><%= user.user.tags[i] %></li>
        <%
            } 
        %>
    </div>
    <div class ="team-list">
        <ul class="ui-row">
    <% 
        if(userTeam.teams.length > 0) {
    %>
        
        <% 
            for(var i = 0; i < userTeam.teams.length; i++) {
            var leader = userTeam.teams[i].seats.filter(function(seat) {
                if(seat.userId) {
                    return seat.userId == user.user.userId
                }
            })
            var range = []
            userTeam.teams[i].seats.filter(function(seat) {
            
                range.push(seat.rent)
            })
            var rangeDiff = range.sort();
            
        %>
            <li class="ui-col ui-col-50 padding-no" style ="position:relative;">
                <img src="<%= userTeam.teams[i].houseCover %>?w=640&q=60" alt="">
                <% 
                    
                    if(leader.length > 0 && leader[0].leader) {
                %>
                <span class ="room-type">作为<strong>室长</strong>的房源</span>
                <%
                    } else {
                %>
                <span class ="room-type">作为<strong>室友</strong>的房源</span>
                <%
                    } 
                %>
            </li>
            <li class="ui-col ui-col-50">
                <p><strong><%= userTeam.teams[i].houseCommunity %></strong></p>
                <p class="brand-color">¥<%= rangeDiff[0] %> 元 - <%= rangeDiff[rangeDiff.length-1] %> <small>起</small></p>
                <p><div class="ui-nowrap ui-whitespace ui-txt-muted"><%= userTeam.teams[i].houseRegion %> | <%= userTeam.teams[i].houseRoomNum %>室<%= userTeam.teams[i].houseHallNum %>厅<%= userTeam.teams[i].houseToiletNum %>卫 | <%= userTeam.teams[i].houseArea %>㎡</div></p>
                <% 
                    if(userTeam.teams[i].houseSeemode) {
                %>
                <p class ="check"><img src="/app/static/img/business.png" alt=""><%= userTeam.teams[i].houseSeemode %></p>
                <%
                    } else {
                %>
                <p class ="check"><img src="/app/static/img/business.png" alt="">不提供带看</p>
                <%
                    } 
                %>
                <% 
                    if(userTeam.teams[i].houseCheck) {
                %>
                <p class ="check"><img src="/app/static/img/check.png" alt="">房妈妈验房保证</p>
                <%
                    } else {
                %>
                <p class ="check"><img src="/app/static/img/check.png" alt="">房妈妈未验房</p>
                <%
                    } 
                %>
            </li>
            <li class="ui-col ui-col-100" id ="select-room">
                <span>加入寝室</span>
            </li>
        <%
            } 
        %>
    <% 
        } else {
    %>
    <p class="center" style="padding: 8px">列表为空</p>
    <% 
        } 
    %>
        </ul>
    </div>
    <script type="text/javascript" src ="/app/static/js/zepto.min.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src ="/app/static/js/customalert.js"></script>
    <script>
    $(function() {
        function alert(str) {
            $.customalert({
                content: str
            })
        }
        $("#select-room span").on('click', function(event) {
            alert('<a href="http://a.app.qq.com/o/simple.jsp?pkgname=com.fangmm.housemother">点击下载房妈妈App，加入合租生活</a>')
        });
    })
    
    wx.config({
        debug: false,
        appId: '<%= jsapiSignature.appId %>',
        timestamp: "<%= jsapiSignature.timestamp %>",
        nonceStr: '<%= jsapiSignature.noncestr %>',
        signature: '<%= jsapiSignature.signature %>',
        jsApiList: [
            'onMenuShareTimeline',
            'onMenuShareAppMessage'
        ]
    });


    wx.ready(function(){

        wx.onMenuShareTimeline({
            title: '<%= user.user.name %>已经开好房了，洗白白等你来哟~',
            link: '',
            imgUrl: '<%= user.user.avatar %>',
            success: function () {

            },
            cancel: function () {
                alert("您取消了分享链接！");
            }
        });

        wx.onMenuShareAppMessage({
            title: '<%= user.user.name %>已经开好房了，洗白白等你来哟~',
            link: '',
            desc: '快来一起合租吧~',
            imgUrl: '<%= user.user.avatar %>',
            type: 'link',
            dataUrl: '',
            success: function () {
            },
            cancel: function () {
                alert("您取消了分享链接！");
            }

        });

    })

    wx.error(function(res){
        var url = 'http://m.fangmm.com/app/client/clear';
        $.get(url, function(data) {
            if(200 == data.code) {
                location.reload();
            }
        }, 'json')
    })
    </script>
    <% include ../partial/analyse %>
</body>
</html>
